home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / dvivga9.zip / READPXL.H < prev    next >
Text File  |  1988-05-30  |  3KB  |  79 lines

  1. /* -*-C-*- readpxl.h */
  2. /*-->readpxl*/
  3. /**********************************************************************/
  4. /****************************** readpxl *******************************/
  5. /**********************************************************************/
  6.  
  7. int
  8. readpxl()    /* return 0 on success, EOF on failure */
  9. {
  10.     UNSIGN32 checksum;
  11.     register struct char_entry *tcharptr;/* temporary char_entry pointer */
  12.     register UNSIGN16 the_char;        /* loop index */
  13.  
  14. #if    (OS_VAXVMS)
  15.     /* VMS binary files are stored with NUL padding to the next 512 byte
  16.     multiple.  We therefore search backwards to the last non-NULL byte
  17.     to the find real end-of-file, then move back 20 bytes from that. */
  18.     FSEEK(fontfp,0L,2);        /* seek to end-of-file */
  19.     while (FSEEK(fontfp,-1L,1) == 0)
  20.     {
  21.         the_char = (UNSIGN16)fgetc(fontfp);
  22.     if (the_char)
  23.       break;        /* exit leaving pointer PAST last non-NUL */
  24.     UNGETC((char)the_char,fontfp);
  25.     }
  26.     if (FSEEK(fontfp,-20L,1))    /* 20 bytes before last non-NUL for checksum */
  27. #else
  28.     if (FSEEK(fontfp,-20L,2))    /* 20 bytes before end-of-file for checksum */
  29. #endif
  30.     {
  31.     (void)warning("readpxl():  FSEEK() failed--PXL font file may be empty");
  32.     return(EOF);
  33.     }
  34.  
  35.     checksum = nosignex(fontfp,(BYTE)4);
  36.     if ((fontptr->c != 0L) && (checksum != 0L) && (fontptr->c != checksum))
  37.     {
  38.     (void)sprintf(message,
  39.     "readpxl():  font [%s] has checksum = 10#%010lu [16#%08lx] [8#%011lo] \
  40. different from DVI checksum = 10#%010lu [16#%08lx] [8#%011lo].  \
  41. TeX preloaded .fmt file is probably out-of-date with respect to new fonts.",
  42.         fontptr->name, fontptr->c, fontptr->c, fontptr->c,
  43.         checksum, checksum, checksum);
  44.     (void)warning(message);
  45.     }
  46.     fontptr->magnification = nosignex(fontfp,(BYTE)4);
  47.     fontptr->designsize = nosignex(fontfp,(BYTE)4);
  48.     if (FSEEK(fontfp, (long)(nosignex(fontfp,(BYTE)4) << 2), 0))
  49.     {
  50.     (void)warning(
  51.     "readpxl():  FSEEK() did not find PXL font file character directory");
  52.     return(EOF);
  53.     }
  54.  
  55.     for (the_char = FIRSTPXLCHAR; the_char <= LASTPXLCHAR; the_char++)
  56.     {
  57.     tcharptr = &(fontptr->ch[the_char]);
  58.     tcharptr->wp = (COORDINATE)nosignex(fontfp,(BYTE)2);
  59.     tcharptr->hp = (COORDINATE)nosignex(fontfp,(BYTE)2);
  60.     tcharptr->xoffp = (COORDINATE)signex(fontfp,(BYTE)2);
  61.     tcharptr->yoffp = (COORDINATE)signex(fontfp,(BYTE)2);
  62.  
  63.     /* convert (32-bit) word pointer to byte pointer */
  64.     tcharptr->fontrp = (long)(nosignex(fontfp,(BYTE)4) << 2);
  65.  
  66.     tcharptr->tfmw = (UNSIGN32)(((float)nosignex(fontfp,(BYTE)4) *
  67.         (float)fontptr->s) / (float)(1L<<20));
  68.     tcharptr->pxlw = (UNSIGN16)PIXROUND((INT32)(tcharptr->tfmw), conv);
  69.     tcharptr->refcount = 0;            /* character unused */
  70.     tcharptr->rasters = (UNSIGN32*)NULL;    /* no raster description */
  71.     }
  72.  
  73. #if    (BBNBITGRAPH | HPJETPLUS | POSTSCRIPT | IMPRESS | CANON_A2)
  74.     (void)newfont();
  75. #endif
  76.  
  77.     return(0);
  78. }
  79.